#include<bits/stdc++.h>
using namespace std;
struct node
{
	int val;
	int sz;
	node(int val,int sz)
	{
		this->val=val;
		this->sz=sz;
	}
};
bool cmp(node x,node y)
{
	if(x.sz==y.sz)
	{
		return x.val<y.val;
	}
	else
	return x.sz>y.sz;
}
int n;
vector<node> v;
int len(int x)
{
	int ans=0;
	x=abs(x);
	while(x)
	{
		ans++;
		x/=10;
	}
	return ans;
}
int main()
{
	//cin>>n;
	int x;
	while(cin>>x){
		v.push_back(node(x,len(x)));
		char c='0';
		c=cin.get();
		if(c=='\n')break;
		
	}
	sort(v.begin(),v.end(),cmp);
	for(auto t:v)cout<<t.val<<" ";
	return 0;
}
